package com.myway.front.controller;

import com.myway.front.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/user")
public class LoginController {
    @Autowired
    private LoginService loginService;

    /**
     * 手机短息验证登陆
     * @param phoneNumber
     * @param code
     * @param request
     * @return
     */
    @RequestMapping("/phoneLogin")
    public String phoneLogin(String phoneNumber,String code,HttpServletRequest request){
        String status = loginService.phoneLogin(phoneNumber,code,request);
        if(status=="ok"){
            return "hotel";
        } else {
            return "login";
        }
    }

    /**
     * 获取短息验证码
     * @param phoneNumber
     * @param request
     * @return
     */
    @RequestMapping("/getCode")
    @ResponseBody
    public String getCode(String phoneNumber, HttpServletRequest request){
        return loginService.getCode(phoneNumber,request);
    }
}



